const path = require('path');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
 entry:'./public/index.js',   //打包的入口文件
 output:{
   path:path.resolve(__dirname,'dist'),    //出口文件路径
   filename:'bundle.js'                    //出口文件名字
 },
 module: {
    rules: [
      {
        test: /.css$/,
        use: [
          // 注意：顺序上不能改动
          'style-loader',
          'css-loader'
        ]
      },
      {
        test: /\.scss$/,
        use: [
          {
            loader: MiniCssExtractPlugin.loader
          },
          {
            // Interprets CSS
            loader: "css-loader",
            options: {
              importLoaders: 2
            }
          },
          {
            loader: 'sass-loader' // 将 Sass 编译成 CSS
          }
        ]
      }
    ]
 }
}